<?php
/*
   兑换日志表
*/
namespace common\models\finance;
use common\models\BaseModel;

class ExchangeLogModel extends BaseModel
{
	public static function tableName()
	{
		return "{{%exchange_log}}";
	}

	public function rules() 
	{
		return [
			[['member_id','money','btype1','btype2'],'required'],
			[['service_charge','price1','price2','money'],'safe'],
			[['member_id','state','create_time','update_time'],'integer'],
		];
	}



	/*
		* 兑换列表
		* whereArr 条件
		* params 基本参数 包含 field order page limit
		* extends  扩展信息 一些相关的信息
		* 
	*/	
	public static function exchangeList($whereArr,$params,$extends=array())
	{
		$model  = self::find();
		$where  = $whereArr['where'];
		$whereAnd = isset($whereArr['whereAnd'])?$whereArr['whereAnd']:[];
		$models = self::queryFormart($model,$where,$params,$whereAnd);
		$model  = $models['model'];
		self::$pages = $models['pages'];

		$data  = $model->asarray()->all();
		if(!$data) return array();

		//扩展信息
		if(!$extends) return $data;
		return $data;	
	}	


}